<?php
namespace app\index\controller;
use think\Config;
use think\Controller;
use think\Db;
use think\helper\Str;
use think\Model;
use think\view;
use think\Request;
use Ofcold\IdentityCard\IdentityCard;
use think\exception;
class Report extends Base
{
    public function index()
    {
        return view();
    }
    //
    /***
     *   查询新冠上传信息
     */
    public function IsUploadSars()
    {
        $ybid = $_GET['ybid'];
        $yytm = $_GET['yytm'];
        $data = Db::query("SELECT * FROM Wuhan_SendLog2 where  ybid = :ybid or ybid = :yytm",['ybid'=>$ybid,'yytm'=>$yytm]);
        if($data){
            return layshow('0','success',20, $data);
        }
        return layshow('0','error',20, $data);
    }



    //根据 cdrq, ybbh,yqdh 来查询结果信息
    public function EditReportXmcdz($yqdh = '', $ybbh = '', $cdrq = '')
    {
        $data['yqdh'] = trim($_GET['yqdh']);
        $data['$ybbh'] = trim($_GET['ybbh']);
        $data['$cdrq'] = trim(date("Y-m-d H:i:s", $_GET['cdrq']));
        if (empty($data['yqdh']) || empty($data['$ybbh']) || empty($data['$cdrq'])) {
            $this->error('非法数据', 'report/index');
        }
        //开始查询
        $data = Model('report')->GetReportByYCY($yqdh, $data['$cdrq'], $ybbh);
        $this->assign('data', $data);
        return $this->fetch('report/xmzedit');
    }

    //根据 cdrq, ybbh,yqdh 来查询结果信息  返回 json - layui
    public function layEditReportXmcdz($yqdh = '', $ybbh = '', $cdrq = '')
    {
        $data['yqdh'] = $_GET['yqdh'];
        $data['$ybbh'] = $_GET['ybbh'];
        $data['$cdrq'] = date("Y-m-d H:i:s", $_GET['cdrq']);
        if (empty($data['yqdh']) || empty($data['$ybbh']) || empty($data['$cdrq'])) {
            $this->error('非法数据', 'report/index');
        }
        //开始查询
        $res = Model('report')->GetReportByYCY($yqdh, $data['$cdrq'], $ybbh);
        return layshow('0','success',20, $res);
    }

    //根据 cdrq, ybbh,yqdh,xmdh 来修改结果信息
    public function EditXmcdzByYxyx()
    {
        $yqdh = $_POST['yqdh'];
        $cdrq = date("Y-m-d H:i:s",$_POST['cdrq']);
        $ybbh = $_POST['ybbh'];
        $xmdh = $_POST['xmdh'];
        if(empty($yqdh)||empty($cdrq)||empty($ybbh)||empty($xmdh)){
            return layshow('0','数据不合法',20, []);
        }
        $_POST['cdrq'] = $cdrq;
        $res = Model('report')->ModifyReportByYCY($yqdh, $cdrq, $ybbh, $xmdh, $_POST);
        if ($res) {
            //修改成功  开始重新生成
            Model('common')->ModifyReportStatusByYYC($cdrq,$ybbh,$yqdh);
            //记录修改的信息
            Model('Log')->AddLog("修改了仪器平台:$yqdh.检验日期:$cdrq.流水号:$ybbh.报告结果", 1, $xmdh);
            return layshow('1','修改成功',20, $res);
        }
            return layshow('0','修改失败',20, $res);
    }
    //根据 cdrq, ybbh,yqdh 来删除结果信息
    public function DelXmcdzByYxyx()
    {
        $yqdh = trim($_POST['yqdh']);
        $cdrq = trim($_POST['cdrq']);
        $ybbh = trim($_POST['ybbh']);
        $xmdh = trim($_POST['xmdh']);
        $res = Model('report')->DelReportByYCY($yqdh, $cdrq, $ybbh, $xmdh);
        if ($res) {
            //记录删除的信息
            Model('Log')->AddLog("删除了$yqdh.$cdrq.$ybbh.报告结果", 1, $xmdh);
            return layshow('1','删除成功',20, $res);
        }
        return layshow('0','删除失败',20, $res);
    }

    //根据 cdrq, ybbh,yqdh 来删除结果信息
    public function DelXmcdzByYxyxBetween()
    {
        $yqdh = $_POST['yqdh'];
        $cdrq = $_POST['cdrq'];
        $ybbh = $_POST['ybbh'];
        $xmdh = $_POST['xmdh'];
        $res = Model('report')->DelReportByYCY($yqdh, $cdrq, $ybbh, $xmdh);
        if ($res) {
            return layshow('1','删除成功',20, $res);
        }
        return layshow('0','删除失败',20, $res);
    }

    //根据 ybid 来修改结果信息
    public function EditReportYbid($ybid = '',$ybbh ='')
    {
        $ybid = trim($_GET['ybid']);
        $ybbh = trim($_GET['ybbh']);
        $cdrq = trim($_GET['cdrq']);
        $data = Model('report')->GetReportInfoByYbidAndYqdh($ybid,$ybbh,$cdrq);
        
        $jymd   = Db::query("SELECT jymddh,jymdmc FROM xt_jymd ");
        
        $this->assign(['data' => $data, 'jymdac' =>$jymd]);
        return $this->fetch('report/info');
    }

    //根据 post提交数据 来修改常规项目结果信息
    public function ReportEditinfo()
    {
        if (request()->isPost()) {
            
            //$data=input('post.');
            //转换下标本种类， 年龄男女
            $_POST['bbzl'] = Model('common')->GetBbzlNumber($_POST['bbzl']);
            $_POST['brxb'] = ResetXB($_POST['brxb']);
            //开始更新数据
            $res = Model('Report')->allowField(true)->save($_POST, ['ybid' => $_POST['ybid'],'yqdh' =>$_POST['yqdh']]);
            $sql_order_action = db('lis_ybxx')->getLastSql();

            //这儿更新两个字段  核酸自动上传
            $ybid = $_POST['ybid'];
            Db::table('lis_ybxx')->execute("update lis_ybxx set defstr3 = null ,resultdesc = null where ybid = :ybid",['ybid'=>$ybid]);

            if ($res) {
                //更新成功 开始重新生成
                Model('Common')->ModifyReportStatus($_POST['ybid']);

                //开始记录
                Model('Log')->AddLog('更新修改了一份常规报告记录', 1, $_POST['ybid'],$sql = $sql_order_action);

                $this->success('修改成功 正在重新生成', 'report/index');
            }
            $this->error('更新失败', 'report/index');
        }
    }
    //idnumber修改页面
    public function idedit()
    {
        return view('report/idcard');
    }

    //批量大规模报告生成主页
    public function largereset()
    {
        return view('report/largereset');
    }

    public function largeresetReport()
    {
        $retybid = (trim($_POST['largereset']));

        if (empty($retybid)) {
            $this->error('数据格式错误,不能为空', 'report/largereset');
        }

        $res = Model('common')->ModifyReportStatusAll($retybid);

        if (!$res) {
            $this->error('更新失败', 'report/largereset');
        }
        //正在生成的报告数量
        $count = Model('common')->getReportCreateNow();
        $this->success("更新成功，还有{$count}条正在生成", 'report/largereset');
    }

    //重新生成报告
    public function ReportRet()
    {
        $ybid = $_POST['ybid'];
        if (!trim($ybid) || strlen($ybid) != 12) {
            show('0', '不能为空或者位数不正确');
        }
        $data = Db::table('Lis_ReportTasks')->where('Barcode', $ybid)->update(['ProcessFlag' => 0,'MergeFlag'=>99]);
        if ($data != 0) {
            //开始记录重新生成成功
            Model('Log')->addLog("重新生成了一份报告.$ybid.****", 1, $ybid);
            show('1', '重新生成成功');
        }
        //开始记录为啥生成失败
        $data_lis = Db::query ("select ybid from lis_ybxx where  ybid =:ybid AND ybzt IN ('s','p')",['ybid'=>$ybid]);
        if(!$data_lis){
            show('0', '标本未接入平台或者没审核--请判断');
        }
        $res= Db::execute ("
                    INSERT dbo.Lis_ReportTasks
                    (
                        InstrumentId,
                        TestDate,
                        SampleNo,
                        EntityId,
                        ProcessType,
                        ProcessFlag,
                        ProcessDate,
                        ProcessResult,
                        Barcode,
                        TasksDate,
                        MergeFlag
                    )
SELECT yqdh,cdrq,ybbh,'','upload','0',GETDATE(),'',ybid,GETDATE(),'99999' 
FROM dbo.lis_ybxx  WHERE ybid =:ybid AND ybzt IN ('s','p') ",['ybid'=>$ybid]);
        if ($res) {
            //开始记录重新生成成功
            Model('Log')->addLog("重新生成了一份*大筛*报告.$ybid.****", 1, $ybid);
            show('1', '大筛生成成功');
        }
            show('0', '大筛生成失败');

    }

    //重新生成大筛报告
    public function DsReportRet()
    {
        $ybid = $_POST['ybid'];
        if (!trim($ybid) || strlen($ybid) != 12) {
            show('0', '不能为空或者位数不正确');
        }
        $res= Db::execute ("
                    INSERT dbo.Lis_ReportTasks
                    (
                        InstrumentId,
                        TestDate,
                        SampleNo,
                        EntityId,
                        ProcessType,
                        ProcessFlag,
                        ProcessDate,
                        ProcessResult,
                        Barcode,
                        TasksDate,
                        MergeFlag
                    )
SELECT yqdh,cdrq,ybbh,'','upload','0',GETDATE(),'',ybid,GETDATE(),'99999' 
FROM dbo.lis_ybxx  WHERE ybid =:ybid AND ybzt IN ('s','p') ",['ybid'=>$ybid]);
        if ($res) {
            //开始记录重新生成成功
            Model('Log')->addLog("重新生成了一份*大筛*报告.$ybid.****", 1, $ybid);
            show('1', '大筛生成成功');
        }
        show('0', '大筛生成失败');
    }

    //获取样本信息 --ajax
    public function ReportInfo()
    {
        $data = trim(input('post.'));
        if (empty($data['ybid'])) {
            show('0', '样本号不能为空');
        }
        if (strlen($data['ybid']) != 12) {
            show('0', '样本号位数必须为12位');
        }
        $res = Model('report')->GetReportInfoByYbid($data['ybid']);
        if (!$res) {
            show('0', '该样本不存在');
        }
        $aa = (array)$res;
        show('1', '结果已返回', $aa);
    }

    // //获取样本信息 --post
    public function ReportInfoPost()
    {
        $data = input('post.');
        //validate验证
        $val = new \app\index\validate\Report();
        if (!$val->check($data)) {
            $this->error($val->getError());
            exit;
        }
        $res = Model('report')->GetReportInfoByYbid(trim($data['ybid']));
        if (!$res) {
            $this->error("该条码不存在", 'report/idedit');
        }
        foreach ($res as $aa) {
            $this->assign('res', $aa);
            return $this->fetch('report/idcard');
        }
    }

    //快速修改身份证
    public function ModifyID()
    {
        $data = input('post.');
        if (empty($data['ybid']) || empty($data['idnumber'])) {
            $this->error("ybid,idnumber 不能为空", 'report/idedit');
        }
        /* if(strlen($data['ybid']) !=12 || strlen($data['idnumber']) !=18){
             $this->error("样本号位数或者身份证位数不正确",'report/idedit');
         }*/
        //查找到审核的报告报告单
        $res = Model('report')->GetReportInfoByYbid(trim($data['ybid']));
        if (!$res) {
            $this->error("该样本不存在或者未审核", 'report/idedit');
        }
        //开始修改修改身份证
        if (!Model('report')->ModifyIdnumber($data['ybid'], $data['idnumber'])) {
            $this->error("修改失败", 'report/idedit');
        }

        $numberend = $data['idnumber'];
        //修改成功--开始重新生成报告单
        if (Model('common')->ModifyReportStatus($data['ybid'])) {
            //log记录修改信息
            Model('Log')->addLog("修改身份证信息为.$numberend", 1, $data['ybid']);

            $this->error("修改成功-重新生成成功", 'report/idedit');
        }
        $this->error("修改成功-重新生成失败", 'report/idedit');
    }
    //report detail post
    // //获取样本信息 --post  --查询主界面
    public function DetailReportInfo()
    {
        //$data = input('post.');
        if (!trim($_POST['str'])) {
            /*$this->error('--名称--不能为空失败');*/
            $this->error("查询条件不能为空", 'report/index');
        }
        //判断post str 类型
        if (Model('common')->IdOrUsername(trim($_POST['str']))) {
            //输入的是汉字
            $res = Model('report')->GetReportInfoByBrxm(trim($_POST['str']));
            if (!$res) {
                $this->error("该送检姓名不存在", 'report/index');
            }
            $this->assign('ReportRes', $res);
            return $this->fetch('report/index');
        }
        //判断字符串长度， 等于18位 就是身份证号码   --GetReportInfoByIdNumber
        if (strlen(trim($_POST['str'])) == 18) {
            $res = Model('report')->GetReportInfoByIdNumber(trim($_POST['str']));
            if (!$res) {
                $this->error("该身份证号码不存在", 'report/index');
            }
            $this->assign('ReportRes', $res);
            return $this->fetch('report/index');
        }
        //判断字符串长度  不等于12位  就是yytm
        if (strlen(trim($_POST['str'])) !== 12) {
            $res = Model('report')->GetReportInfoByYytm(trim($_POST['str']));
            if (!$res) {
                $this->error("该医院条码不存在", 'report/index');
            }
            $this->assign('ReportRes', $res);
            return $this->fetch('report/index');
        }

        $res = Model('report')->GetReportInfoByYbid(trim($_POST['str']));
        if (!$res) {
            $this->error("该千麦条码不存在", 'report/index');
        }
        $this->assign('ReportRes', $res);
        return $this->fetch('report/index');
    }

    //病理系统
    public function blindex()
    {
        return view('report/blindex');
    }

    //获取病理查询的界面信息
    public function DetailBlReportInfo()
    {
        $data = input('post.');
        if (!trim($data['str'])) {
            /*$this->error('--名称--不能为空失败');*/
            $this->error("病理不能为空", 'report/blindex');
        }
        //判断post str 类型
        if (Model('common')->IdOrUsername(trim($data['str']))) {
            //输入的是汉字
            $res = Model('BlReport')->GetBlReportInfoByBrxm(trim($data['str']));
            if (!$res) {
                $this->error("该送检姓名不存在", 'report/blindex');
            }
            $this->assign('ReportRes', $res);
            return $this->fetch('report/blindex');
        }
        $res = Model('BlReport')->GetReportBlInfoByYbid(trim($data['str']));
        if (!$res) {
            $this->error("该千麦条码不存在", 'report/blindex');
        }
        $this->assign('ReportRes', $res);
        return $this->fetch('report/blindex');
    }

    //根据 ybid 来修改Bl结果信息
    public function EditBlReportYbid($ybid = '')
    {
        $ybid = $_GET['ybid'];
        $data = Model('BlReport')->GetReportBlInfoByYbid($ybid);
        $this->assign('data', $data);
        return $this->fetch('report/blinfo');
    }
    /*BL 修改后的数据post 修改*/
    public function ReportBlEditinfo()
    {
        if (request()->isPost()) {
            $_POST['brsex'] = ResetXB($_POST['brsex']);
            $res = Model('BlReport')->updatebl($_POST['ybid'],$_POST);
            $sql_order_action = db('T_bljbxxb')->getLastSql();
            if ($res) {
                //更新成功 开始重新生成
                Model('Common')->ModifyReportStatus($_POST['ybid']);
                //开始记录
                Model('Log')->AddLog('更新修改了一份Bl报告记录', 1, $_POST['ybid'],$sql = $sql_order_action);
                $this->success('修改成功 正在重新生成', 'report/blindex');
            }
            $this->error('更新失败', 'report/blindex');
        }
    }

    //tct系统-----tct
    public function tctindex()
    {
        return view('report/tctindex');
    }
    //获取病理tct的界面信息
    public function DetailtctReportInfo()
    {
        $data = input('post.');
        if (!trim($data['str'])) {
            /*$this->error('--名称--不能为空失败');*/
            $this->error("条码不能为空", 'report/tctindex');
        }

        //判断post str 类型
        if (Model('common')->IdOrUsername(trim($data['str']))) {
            //输入的是汉字
            $res = Model('TctReport')->GettctReportInfoByBrxm(trim($data['str']));
            if (!$res) {
                $this->error("该送检姓名不存在", 'report/tctindex');
            }

            $this->assign('ReportRes', $res);
            return $this->fetch('report/tctindex');
        }

        $res = Model('tctReport')->GetReportTctInfoByYbid(trim($data['str']));

        if (!$res) {
            $this->error("该千麦条码不存在", 'report/tctindex');
        }
        $this->assign('ReportRes', $res);
        return $this->fetch('report/tctindex');
    }

    //根据 ybid 查询tct结果信息
    public function EditTctReportYbid($ybid = '')
    {
        /*if (empty($ybid) || strlen($ybid) != 12) {
            $this->error('错误数据', 'report/index');
        }*/
        $ybid = $_GET['ybid'];
        $data = Model('TctReport')->GetReportTctInfoByYbid(trim($ybid));
        $this->assign('data', $data);
        return $this->fetch('report/tctinfo');
    }

    /*TCT修改后的数据post 修改*/
    public function ReportTctEditinfo()
    {
        if (request()->isPost()) {
            //$data=input('post.');
            //转换下标本种类， 年龄男女
            //$_POST['bbzl'] = Model('common')->GetBbzlNumber($_POST['bbzl']);
            $_POST['Brsex'] = ResetXB($_POST['Brsex']);
            //这儿病人年龄有两个
            $_POST['brnl']  = $_POST['Brage'];
            $res = Model('TctReport')->updatetct($_POST['Ybid'],$_POST);
            if ($res) {
                //更新成功 开始重新生成
                Model('Common')->ModifyReportStatus($_POST['Ybid']);
                //$sql_order_action = db('T_tctbgd')->getLastSql();
                //开始记录
                Model('Log')->AddLog('更新修改了一条tct记录', 1, $_POST['Ybid']);
                $this->success('修改成功 正在重新生成', 'report/tctindex');
            }
            $this->error('更新失败', 'report/tctindex');
        }
    }
    //微生物的
    public function wswindex()
    {
        return view('report/wswindex');
    }

    //获取微生物报告的界面信息
    public function DetailWswReportInfo()
    {
        $data = input('post.');
        if (!trim($data['str'])) {
            /*$this->error('--名称--不能为空失败');*/
            $this->error("微生物不能为空", 'report/index');
        }
        //判断post str 类型
        if (Model('common')->IdOrUsername(trim($data['str']))) {
            //输入的是汉字
            $res = Model('WswReport')->GetReportWswInfoByBrxm(trim($data['str']));
            if (!$res) {
                $this->error("该送检姓名不存在", 'report/wswindex');
            }
            $this->assign('ReportRes', $res);

            return $this->fetch('report/wswindex');
        }

        //判断字符串长度， 等于18位 就是身份证号码   --GetReportInfoByIdNumber
        if (strlen($data['str']) == 18) {
            $res = Model('WswReport')->GetWswReportInfoByIdNumber(trim($data['str']));
            if (!$res) {
                $this->error("该身份证号码不存在", 'report/wswindex');
            }
            $this->assign('ReportRes', $res);
            return $this->fetch('report/wswindex');
        }

        //判断字符串长度  不等于12位  就是yytm
        if (strlen($data['str']) !== 12) {
            $res = Model('WswReport')->GetWswReportInfoByYytm(trim($data['str']));
            if (!$res) {
                $this->error("该医院条码不存在", 'report/wswindex');
            }
            $this->assign('ReportRes', $res);
            return $this->fetch('report/wswindex');
        }

        $res = Model('WswReport')->GetWswReportInfoByYbid(trim($data['str']));

        if (!$res) {
            $this->error("该千麦条码不存在", 'report/wswindex');
        }
        $this->assign('ReportRes', $res);
        return $this->fetch('report/wswindex');
    }

    /***
     * 批量更新 报告
     */
    public function UpdateReportByAllYbid(){
        {
            $codes = trim(input('post.code'));
            if(empty($codes)){
                $this->success('不能为空', 'report/largereset');
            }
            $ArrCode = explode("\n", $codes);
            foreach ($ArrCode as $key=>$code){
                if(empty($code)){
                    break;
                }
                Db::execute("update Lis_ReportTasks set ProcessFlag = '' where Barcode = :Barcode", ['Barcode' => $code]);
            }
            //开始记录
            Model('Log')->addLog("批量更新.$codes.的信息**", 1, $codes);
            $this->success('更新成功', 'report/largereset');
        }
    }


    /**
     *  核酸 接口数据上传
     *
     */
    public function GetNa($ybid=''){
        $DATE = Db::table('lis_ybxx')->execute("SELECT '420102018' AS YLJGDM,a.ybid AS SGTXM,'57' AS BBLX,
                REPLACE(a.idnumber,'x','X') AS ZJHM,replace(a.brxm,' ','') AS XM,
                 REPLACE( CONVERT ( NVARCHAR ,a.cjtime,20),'-','') AS CYRQ,
     REPLACE( CONVERT ( NVARCHAR ,a.cjtime,20),'-','') AS SHRQ,
                 '武汉千麦医学检验所有限公司' AS YLJGMC,'420102018' AS JCJGDM,
                 '武汉千麦医学检验所有限公司' AS JCJGMC,'王燕' AS  CYFZR,'13628625070' AS LXFS,
                 a.byh AS CYDD,
                 CASE WHEN (d.JYMDDH = 'S00056' OR d.JYMDDH = 'S00058') THEN '100'
                 WHEN (d.JYMDDH = 'S00059' OR d.JYMDDH = 'S00057') THEN '10' ELSE '1000' END AS HYFS,
                 '420102018' AS SGLYDW,
                 '14' AS RYLX,'9' AS 'BLLX',a.idnumber AS PID,'9' AS YWHDLX,
                 REPLACE( CONVERT ( NVARCHAR ,a.cjtime,20),'-','') AS  JZLSH,
                 '' AS KH,'' AS KLX,'' AS JJCS,'1' AS ZJLX,SUBSTRING(a.idnumber,7,8)  AS CSRQ,
                  CASE WHEN a.brxb = '1' THEN '1' WHEN a.brxb='2' THEN '2' ELSE
                 '9' END AS  XB,'1' AS MZ,'13628625070' AS LXDH,'' AS BCYRDZ_MPH ,'' AS BCYRDZ_XXMS,
                 '' AS LXRXM,'' AS LXRZJHM,'' AS LXRZJLX ,'' AS GXDM, '' AS LXRLXDH,'7' AS SSRQ
                 FROM  dbo.lis_ybxx a 
                JOIN dbo.lis_xmcdz b ON a.cdrq=b.cdrq AND a.ybbh=b.ybbh AND a.yqdh=b.yqdh
                JOIN S_SampleDetail c ON c.S_Barcode=a.ybid AND c.yqdh=a.yqdh
                JOIN S_SampleItem d ON c.id = d.S_SampleId
                WHERE a.yqdh='7500'   AND b.xmdh IN ('500080','500077','S00004')
                AND a.cyrq>=GETDATE()-15 AND ISNULL(a.idnumber,'')!=''
                AND LEN(a.idnumber)=18 AND defstr3 is  null
                AND a.ybzt IN ('S','P')  and ybid = :id  ORDER BY a.bgrq DESC",['ybid'=>$ybid]);

        Db::table('lis_ybxx')->execute(" update lis_ybxx set defstr3 = null ,resultdesc = null where ybid = '616056004424'");
    }

    /**
     * 获取身份证信息
     */
    public function  getInfoByidnumber(){
        $idnumber = $_POST['idnumber'];
        $result = IdentityCard::make($idnumber);
        if ( $result === false ) {

            return layshow('-1','您的身份证号码不正确', '您的身份证号码不正确');
        }
        $data = $result->toArray();
        // $cc= Db::table('lis_ybxx')->field('brxm')->where(['yqdh'=>'7500','idnumber'=> $idnumber,])->find();
        // if(!$cc){
        //     $data['brxm'] = '';
        // }else{
        //     $data['brxm'] = $cc['brxm'];
        // }

        if($result){
            return layshow('1','生成年龄,性别,地址成功', $data );
        }
        return layshow('-1','您的身份证号码不正确', '您的身份证号码不正确');

        /**
         * getArea():string 获取地区
        getConstellation():string 获取星座
        getZodiac() : string 获取生肖
        getAge():int 获取年龄
        getBirthday(string $foramt = 'Y-m-d'):string 获取生日
        getGender():string 获取性别
        getCounty():string|null 获取县城
        getCity():string|null 获取城市
        getProvince():string|null 获取省
        toArray():array 全部信息
        toJson(int $option):string 全部信息
         */
    }


    /**
     * 获取身份证信息
     */
    public function  getYbxxTime(){
        $data['cyrq'] = date('Y-m-d H:i:s', strtotime("-4 hour"));
        $data['cjtime'] = date('Y-m-d H:i:s', strtotime("-6 hour"));;
        $data['bgrq'] = date('Y-m-d H:i:s', time());;
        return layshow('1','成功', $data );
    }

    /**
     * 新冠查询 chart
     */

     public function ApiGetReportConut(){

        try { 
            $datatime = $_POST['datetime'];   
        } catch(Exception $e) {
            $datatime =   date('Y-m-d');
        }
         $data = Db::table('lis_ybxx')->query("select  top 10 byh as name,COUNT(*) as num from lis_ybxx where yqdh = '7500' 
         and  cdrq = :cdrq and jymd like '新型%' group by byh order by num desc ",['cdrq'=>$datatime]);
        
        //  $data = Db::table('lis_ybxx')->where('cdrq',date('Y-m-d'))->select(); date('Y-m-d')
        show(200,'success',$data);

        }
        
}